home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Mathematics / Notebooks / SigProc2.0 / Packages / SignalProcessing / Digital / Correlation.m next >
Encoding:
Text File  |  1992-08-18  |  3.2 KB  |  122 lines

  1. (*  :Title:    Correlation  *)
  2.  
  3. (*  :Authors:    Brian Evans, James McClellan  *)
  4.  
  5. (*
  6.     :Summary:    Perform basic analysis on a one-dimensional discrete-time
  7.         function, including plotting f[n] and graphing the poles
  8.         and zeroes of F[z].
  9.  *)
  10.  
  11. (*  :Context:    SignalProcessing`Digital`Correlation`  *)
  12.  
  13. (*  :PackageVersion:  2.7    *)
  14.  
  15. (*
  16.     :Copyright:    Copyright 1989-1991 by Brian L. Evans
  17.         Georgia Tech Research Corporation
  18.  
  19.     Permission to use, copy, modify, and distribute this software
  20.     and its documentation for any purpose and without fee is
  21.     hereby granted, provided that the above copyright notice
  22.     appear in all copies and that both that copyright notice and
  23.     this permission notice appear in supporting documentation,
  24.     and that the name of the Georgia Tech Research Corporation,
  25.     Georgia Tech, or Georgia Institute of Technology not be used
  26.     in advertising or publicity pertaining to distribution of the
  27.     software without specific, written prior permission.  Georgia
  28.     Tech makes no representations about the suitability of this
  29.     software for any purpose.  It is provided "as is" without
  30.     express or implied warranty.
  31.  *)
  32.  
  33. (*  :History:    *)
  34.  
  35. (*  :Keywords:    cross-correlation, autocorrelation    *)
  36.  
  37. (*  :Source:    *)
  38.  
  39. (*  :Warning:    *)
  40.  
  41. (*  :Mathematica Version:  1.2 or 2.0  *)
  42.  
  43. (*  :Limitation:  *)
  44.  
  45. (*  :Discussion:  *)
  46.  
  47. (*  :Functions:    CorrelationSequence  *)
  48.  
  49.  
  50.  
  51. (*  B E G I N     P A C K A G E  *)
  52.  
  53. BeginPackage[ "SignalProcessing`Digital`Correlation`",
  54.           "SignalProcessing`Digital`InvZTransform`",
  55.           "SignalProcessing`Digital`ZTransform`",
  56.           "SignalProcessing`Digital`ZSupport`",
  57.           "SignalProcessing`Support`TransSupport`",
  58.           "SignalProcessing`Support`ROC`",
  59.           "SignalProcessing`Support`SigProc`",
  60.           "SignalProcessing`Support`SupCode`" ]
  61.  
  62.  
  63. If [ TrueQ[ $VersionNumber >= 2.0 ],
  64.      Off[ General::spell ];
  65.      Off[ General::spell1 ] ];
  66.  
  67.  
  68. (*  U S A G E     I N F O R M A T I O N  *)
  69.  
  70. CorrelationSequence::usage =
  71.     "CorrelationSequence[x,n,z] or CorrelationSequence[X,n,z] will \
  72.     return the correlation sequence as discrete-time function of n. \
  73.     Note that the first argument can be either a sequence x[n] or \
  74.     a z-transform X(z).  Also note that the last two arguments are \
  75.     optional."
  76.  
  77. (*  E N D     U S A G E     I N F O R M A T I O N  *)
  78.  
  79.  
  80. Begin["`Private`"]
  81.  
  82.  
  83. (*  A u t o c o r r e l a t i o n  *)
  84.  
  85. CorrelationSequence[x_, n_:Null, z_:Null] := 
  86.     Block [    {nvars, xzinv, zvars},
  87.         zvars = ZVariables[x];
  88.         nvars = If [ SameQ[n, Null],
  89.                  DummyVariables[Length[zvars], Global`n],
  90.                  n ];
  91.         xzinv = MakeZObject[ { TheFunction[x] /. zvars ~ReplaceWith~ (zvars^-1), 1 / GetRPlus[x], 1 / GetRMinus[x] }, zvars ];
  92.         InvZTransform[x xzinv, zvars, nvars] ] /;
  93.     ZTransformQ[x]
  94.  
  95. CorrelationSequence[x_, n_:Global`n, z_:Global`z] := 
  96.     Block [    {Cxx, negx},
  97.         negx = x /. n ~ReplaceWith~ (-n);
  98.         Cxx = ZTransform[x, n, z] ZTransform[negx, n, z];
  99.         InvZTransform[ Cxx ] ]
  100.  
  101.  
  102. (*  E N D     P A C K A G E  *)
  103.  
  104. End[]
  105. EndPackage[]
  106.  
  107. If [ TrueQ[ $VersionNumber >= 2.0 ],
  108.      On[ General::spell ];
  109.      On[ General::spell1 ] ];
  110.  
  111.  
  112. (*  H E L P     I N F O R M A T I O N  *)
  113.  
  114. Combine[SPfunctions, { CorrelationSequence } ]
  115. Protect[CorrelationSequence]
  116.  
  117.  
  118. (*  E N D I N G     M E S S A G E  *)
  119.  
  120. Print["Correlation functions are now loaded."]
  121. Null
  122.